class Solution {
    void my_reverse(vector<int>& nums, int left, int right)
    {
        while (left < right)
        {
            int tmp = nums[left];
            nums[left] = nums[right];
            nums[right] = tmp;
            left++;
            right--;
        }
    }
public:
    void rotate(vector<int>& nums, int k) {
        int sz = nums.size();
        k %= nums.size();
        my_reverse(nums, 0, sz - 1);
        my_reverse(nums, 0, k - 1);
        my_reverse(nums, k, sz - 1);

        /*reverse(nums.begin(), nums.end());
        reverse(nums.begin(), nums.begin() + k);
        reverse(nums.begin() + k, nums.end());*/
    }
};